package com.diandian.orc.yunmai;

import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.Base64;
import java.util.HashMap;
import java.util.Map;

import com.diandian.util.Base64Util;
import com.diandian.util.HttpUtils;

/**
 * @description YunMai 云脉 http://www.yunmaiocr.com/goDoc
 * @author TDW
 * @date 2018年8月6日
 *
 */
public class YunMaiTest {

//	private static String url = "http://www.baidu.com";
	private static String url = "http//www.yunmaiocr.com/srvSAASAPI";

	public static void main(String[] args) {
//		String param = "action=doc&baseFile=BF&client=fb1da037-6a72-4a68-81cb-5e0f4de89bbd"
//				+ "&password=uJChyZQtSZKVvGLaLUgzQsBOVtVfKC&ocrLang=0&ext=png&system&returnType=";

		String imgFile = "C:\\Users\\Administrator\\Desktop\\test3.png";// 待处理的图片
		InputStream in = null;
		byte[] data = null;
		// 读取图片字节数组
		try {
			in = new FileInputStream(imgFile);
			data = new byte[in.available()];
			in.read(data);
			in.close();
			String fileCode = Base64Util.encode(data);
			Map<String, String> map = new HashMap<String, String>();
			map.put("action", "doc");
			map.put("baseFile",fileCode);
			map.put("client","fb1da037-6a72-4a68-81cb-5e0f4de89bbd");
			map.put("password","uJChyZQtSZKVvGLaLUgzQsBOVtVfKC");
			map.put("ocrLang","0");
			map.put("ext","png");
			map.put("system","windows");
//			map.put("system","windows");
//			System.out.println(HttpUtils.doGet(url));
			System.out.println(HttpUtils.doPost(url, map));
			
			
		} catch (IOException e) {
			e.printStackTrace();
		}
	}

}
